var Sequelize = require("sequelize");

module.exports = function(sequelize, DataTypes) {
  var User = sequelize.define("User", {
    id: { type: Sequelize.INTEGER, primaryKey: true,autoIncrement: true },
    name: { type: Sequelize.STRING},
    sex :  { type: Sequelize.INTEGER},
    mobile :  { type: Sequelize.STRING},
    email :  { type: Sequelize.STRING},
    password :  { type: Sequelize.STRING},
    status :  { type: Sequelize.INTEGER},
    headimg :  { type: Sequelize.STRING}
    
  }, {
    tableName: 'uc_user',
    comment: '用户基础表',
    
    underscore: true,
    'timestamps': true,
    'paranoid': true,
    'createdAt' : 'create_time',
    'updatedAt' : 'update_time',
    'deletedAt' : 'delete_time',
    classMethods: {
      associate: function(models) {
        //User.hasMany(models.Passport);
      }
    },
    instanceMethods: {
    toJSON: function () {
      var values = Object.assign({}, this.get());
      delete values.password;    
      //delete values.id;  // maybe remove this line 
      return values;
    }
  }
  });
  return User;
};


/**
 * // 自定义表名
        'freezeTableName': true,
        'tableName': 'xyz_users',

        // 是否需要增加createdAt、updatedAt、deletedAt字段
        'timestamps': true,

        // 不需要createdAt字段
        'createdAt': false,

        // 将updatedAt字段改个名
        'updatedAt': 'utime'

        // 将deletedAt字段改名
        // 同时需要设置paranoid为true（此种模式下，删除数据时不会进行物理删除，而是设置deletedAt为当前时间
        'deletedAt': 'dtime',
        'paranoid': true
 */